package com.yonyou.pmclouds.billview.controller;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import com.alibaba.dubbo.config.annotation.Reference;
import com.yonyou.iuap.print.client.utils.JsonUtil;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.entity.PageObject;
import com.yonyou.pmclouds.basecom.entity.SuperVO;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.runtime.RuntimeEnvironment;
import com.yonyou.pmclouds.basecom.util.BeanHelper;
import com.yonyou.pmclouds.basecom.util.CommonFieldConst;
import com.yonyou.pmclouds.basecom.util.DateUtils;
import com.yonyou.pmclouds.basecom.util.StorageFactory;
import com.yonyou.pmclouds.basecom.view.DisableWrap;
import com.yonyou.pmclouds.billview.config.BillViewPluginFactory;
import com.yonyou.pmclouds.billview.entity.BillViewQueryVO;
import com.yonyou.pmclouds.billview.plugin.IBillViewCustomPlugin;
import com.yonyou.pmclouds.billview.rmitf.BillViewQueryService;
import com.yonyou.pmclouds.businessobject.util.PrintPreviewObj2Html;
import com.yonyou.pmclouds.constructionlog.entity.ConstructionLogVO;
import com.yonyou.pmclouds.outter.enterprise.EnterpriseInfoQuery;
import com.yonyou.pmclouds.outter.role.RoleInfoQuery;
import com.yonyou.pmclouds.outter.tenant.TenantInfoQuery;
import com.yonyou.pmclouds.outter.user.UserInfoQuery;
import com.yonyou.pmclouds.outter.user.UserOperator;
import com.yonyou.pmclouds.project.controller.ProjectCommonRefController;
import com.yonyou.pmclouds.project.entity.ProjectRefVO;
import com.yonyou.pmclouds.project.entity.ProjectVO;
import com.yonyou.pmclouds.siteinspection.entity.SiteInspectionVO;
import com.yonyou.pmclouds.team.entity.TeamMemberVO;
import com.yonyou.pmclouds.team.rmiitf.ProjectRefWithTeamQuery;
import com.yonyou.pmclouds.team.rmiitf.TeamMemberQuery;
import com.yonyou.pmclouds.tenant.entity.TenantInfo;
import com.yonyou.pmclouds.user.entity.UserInfo;
import com.yonyou.pmclouds.user.entity.UserSearchResultVO;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@RestController
@RequestMapping({"/outter/billView","billView"})
public class BillViewController {

    @Reference(version = ApplicationConsts.APPLICATION_VERSION)
    private BillViewQueryService billViewQueryService;
    @Reference(version = ApplicationConsts.APPLICATION_VERSION)
    private TeamMemberQuery teamMemberQuery;
    @Autowired
    private UserInfoQuery userInfoQuery;
    @Autowired
    private EnterpriseInfoQuery enterpriseInfoQuery;
    @Autowired
    private RoleInfoQuery roleInfoQuery;
    @Autowired
    private TenantInfoQuery tenantInfoQuery;
    @Autowired
    private StorageFactory storageFactory;
    @Value("${print.perLineNum}")
    private int perLineNum;
    @Autowired
    private BillViewPluginFactory billViewPluginFactory;
    @Reference(version = ApplicationConsts.APPLICATION_VERSION)
    private ProjectRefWithTeamQuery query;
    @Autowired
    private UserOperator userOperator;

    @RequestMapping(value = "/queryPermProjects")
    public ProjectVO[] queryPermProjects(String pkSrcOrg) {
        ProjectVO[] projectVOs = billViewQueryService.queryPermProjectByOrg(pkSrcOrg);
        return projectVOs;
    }

    @RequestMapping(value = "/getBusiObjectCode")
    public String getBusiObjectCode(String billType) throws BusinessException {
        return billViewQueryService.getBusiObjectCode(billType);
    }

    @RequestMapping(value = "/queryList")
    public PageObject<Object> queryList(@RequestBody @Validated BillViewQueryVO billViewQueryVO) throws BusinessException, IOException {
        //检查日期是否符合规范
        if (!checkDate(billViewQueryVO))
            throw new BusinessException("开始日期不能大于结束日期");
        wrapDefaultCondition(billViewQueryVO);

        if(StringUtils.isNotBlank(billViewQueryVO.getEndTime())){
            //结束日期增加时分秒 已解决不能查询当天数据问题
            String endTime = DateUtils.transToString(DateUtils.asDateEnd(DateUtils.transToDate(billViewQueryVO.getEndTime())));
            billViewQueryVO.setEndTime(endTime);
        }
        return getBillVOs(billViewQueryVO);
    }

    private void wrapDefaultCondition(BillViewQueryVO billViewQueryVO) throws IOException, BusinessException {
        //开工报告 停工单复工单 没有选择项目设置默认查询的项目
        if(StringUtils.isNotEmpty(billViewQueryVO.getBillType())
                && (BillTypeConst.WORKCONNECT_BILLTYPE.equals(billViewQueryVO.getBillType()) || BillTypeConst.WORKSTART_BILLTYPE.equals(billViewQueryVO.getBillType()) ||BillTypeConst.WORKSTOP_BILLTYPE.equals(billViewQueryVO.getBillType()) ||BillTypeConst.REPEATWORK_BILLTYPE.equals(billViewQueryVO.getBillType()))
                &&(billViewQueryVO.getPkProject() == null ||billViewQueryVO.getPkProject().length == 0) ){
            List<String> pkRoles = getRolesByUser(RuntimeEnvironment.getLoginUserId(), RuntimeEnvironment.getTenantId());

            //根据租户下的用户所属的每个角色身份查询其所应的所属组织下的所有项目以及用户所属团队下的所有项目。
            List<String> permissionProjects = query.getPermissionProjects(RuntimeEnvironment.getLoginUserId(), RuntimeEnvironment.getTenantId(), null,
                    Integer.valueOf(0), 1000, pkRoles.toArray(new String[0]));
            billViewQueryVO.setPkProject(permissionProjects.toArray(new String[0]));
        }
    }

    public List<String> getRolesByUser(String userId, String tenantId) throws IOException {
        Map map = userOperator.queryRoleByUserId(tenantId, userId);
        List<String> pkRoles = new ArrayList<>();
        if (map != null && map.get("data") != null) {
            pkRoles = (ArrayList) map.get("data");
        }
        return pkRoles;
    }

    /**
     * 导出（巡查记录/施工记录）
     * @param billViewQueryVO
     * @throws BusinessException
     */
    @RequestMapping(value = "/export")
    public void queryListExport(HttpServletResponse response,@RequestBody @Validated BillViewQueryVO billViewQueryVO) throws IOException, BusinessException {
        //参数验证
        check(billViewQueryVO);
        //填充数据
        fillData(response,billViewQueryVO);
    }

    @RequestMapping(value = "/getUserRefList")
    public UserInfoRefVO[] getUserRefList(String pkProject) throws BusinessException {
        if (StringUtils.isNotEmpty(pkProject)) {
            return getUserInfoByProject(pkProject);
        } else {
            return getUserInfoByTenant();
        }
    }

    /**
     * 获取同时在多个项目的用户
     * @param billViewQueryVO
     * @return
     * @throws BusinessException
     */
    @PostMapping(value = "/getUserInnerSecProjects")
    public PageObject<Object> getUserRefList( @RequestBody BillViewQueryVO billViewQueryVO) throws BusinessException {
        int pageSize = billViewQueryVO.getPageSize();
        int pageNum = billViewQueryVO.getExtendsParams() != null && StringUtils.isNotBlank(billViewQueryVO.getExtendsParams().getString("pageNum")) ?billViewQueryVO.getExtendsParams().getInteger("pageNum") : 0;//Integer.parseInt(billViewQueryVO.getExtendsParams());
        String[] pkProjects = billViewQueryVO.getPkProject();

        PageObject<Object> result = new PageObject<>(new UserInfoRefVO[0], 0, 0);
        getUserInfoByTenant(pageNum, pageSize, result);
        return  result;
//        return teamMemberQuery.getInnerSectionInfoByProjects(pkProjects, (pageNum-1)*pageSize, pageSize);
    }

    /**
     * 根据租户过滤用户
     *
     * @return
     */
    private UserInfoRefVO[] getUserInfoByTenant() {
        return getUserInfoByTenant(0, 500, null);
    }
    /**
     * 根据租户过滤用户
     *
     * @return
     */
    private UserInfoRefVO[] getUserInfoByTenant(int pageNum, int pageSize, PageObject<Object> result) {
        UserSearchResultVO.ContentVO userRefList = userInfoQuery.searchUserInSystem(RuntimeEnvironment.getTenantId(), null, pageNum == 0? 0 :pageNum, pageSize == 0 ? 500 :pageSize, new String[0]);
        UserInfo[] userInfos = userRefList.getContent();
        UserInfoRefVO[] userInfoRefVOs = new UserInfoRefVO[userInfos.length];
        for (int i = 0; i < userInfos.length; i++) {
            UserInfoRefVO userInfoRefVO = new UserInfoRefVO();
            userInfoRefVO.setUserId(userInfos[i].getUserId());
            userInfoRefVO.setUserName(userInfos[i].getUserName());
            userInfoRefVOs[i] = userInfoRefVO;
        }
        if(result != null){
            result.setCount(userRefList.getTotalElements());
            result.setPageStart((pageNum-1)*pageSize);
            result.setObjects(userInfoRefVOs);
        }
        return userInfoRefVOs;
    }
    /**
     * 根据项目过滤用户
     *
     * @param pkProject
     * @return
     * @throws BusinessException
     */
    private UserInfoRefVO[] getUserInfoByProject(String pkProject) throws BusinessException {
        TeamMemberVO[] teamMemberVOs = teamMemberQuery.queryByProject(pkProject);
        String[] pkUsers = new String[teamMemberVOs.length];
        if (ArrayUtils.isEmpty(teamMemberVOs))
            return new UserInfoRefVO[0];

        for (int i = 0; i < teamMemberVOs.length; i++) {
            pkUsers[i] = teamMemberVOs[i].getPkUser();
        }

        Map<String, String> userMap = userInfoQuery.queryUserNames(pkUsers);
        if (userMap == null && userMap.size() == 0)
            return new UserInfoRefVO[0];

        List<UserInfoRefVO> userInfoRefVOList = new ArrayList<UserInfoRefVO>();
        for (String key : userMap.keySet()) {
            UserInfoRefVO userInfoRefVO = new UserInfoRefVO();
            userInfoRefVO.setUserId(key);
            userInfoRefVO.setUserName(userMap.get(key));
            userInfoRefVOList.add(userInfoRefVO);
        }
        return userInfoRefVOList.toArray(new UserInfoRefVO[0]);
    }

    @DisableWrap
    @RequestMapping(value = "/queryBillDetail")
    public Map<String, Object[]> queryBillDetail(HttpServletRequest request) throws BusinessException {

        String pkBill = (String) JsonUtil.jsonToMap(request.getParameter("params")).get("pkBill");
        String billType = (String) JsonUtil.jsonToMap(request.getParameter("params")).get("billType");

        Map<String, Object[]> resultMap = new HashMap<String, Object[]>();

        if (StringUtils.isEmpty(billType))
            throw new BusinessException("单据类型为空");

        if (StringUtils.isEmpty(pkBill))
            throw new BusinessException("单据主键为空");

        SuperVO resultVO = billViewQueryService.queryBillDetail(billType, pkBill);

        if (resultVO == null)
            throw new BusinessException("未查到单据信息");

        if (BeanHelper.getProperty(resultVO, "orgName") == null) {
            TenantInfo tenant = tenantInfoQuery.queryTenantInfoById(RuntimeEnvironment.getTenantId());
            BeanHelper.setProperty(resultVO, "orgName", tenant == null ? null : tenant.getTenantName());
        }

        PrintPreviewObj2Html obj2Html = new PrintPreviewObj2Html(PrintPreviewObj2Html.BASE_PREFIX, PrintPreviewObj2Html.IMG, perLineNum);

        String[] temPictures = BeanHelper.getProperty(resultVO, "pictures") == null ? null : (String[]) BeanHelper.getProperty(resultVO, "pictures");

        if (BeanHelper.getProperty(resultVO, "pictures") != null) {
            String picHtml = obj2Html.urls2Html(storageFactory.getStorageUtil().signUrlForMultiPictures(temPictures, null, request));
            BeanHelper.setProperty(resultVO, "picture_address", picHtml);
            BeanHelper.setProperty(resultVO, "pictureAddress", picHtml);
        }

        IBillViewCustomPlugin plugin = billViewPluginFactory.getBuziPlugin(billType);

        if (plugin == null) {
            resultMap.put(getBusiObjectCode(billType), new Object[]{resultVO});
            return resultMap;
        }

        return plugin.fillDetailBuziField(resultVO, request);

    }

    /**
     * 获取单据查看VO集合（导出用）
     *
     * @param billViewQueryVO
     * @return
     * @throws BusinessException
     */
    private Object[] getBillVOsExport(BillViewQueryVO billViewQueryVO) throws BusinessException {
        PageObject<Object> resultVO = billViewQueryService.queryBillViewList(billViewQueryVO);
        if (ArrayUtils.isEmpty(resultVO.getObjects())) return new PageObject<Object>(new SuperVO[0], 0, billViewQueryVO.getPageStart()).getObjects();
        IBillViewCustomPlugin plugin = billViewPluginFactory.getBuziPlugin(billViewQueryVO.getBillType());
        if (plugin == null)  return resultVO.getObjects();
        //用于补充前端展示信息(翻译施工单位信息，需注意)
        Object[] superVOs = plugin.fillListBuziField(resultVO.getObjects());
        resultVO.setObjects(superVOs);
        userInfoQuery.tranUserInfoField(resultVO.getObjects(), new String[]{CommonFieldConst.CREATOR, CommonFieldConst.CREATOR}, new String[]{CommonFieldConst.CREATOR_NAME, "creator_name"});
        return resultVO.getObjects();
    }


    /**
     * 获取单据查看VO集合
     *
     * @param billViewQueryVO
     * @return
     * @throws BusinessException
     */
    private PageObject<Object> getBillVOs(BillViewQueryVO billViewQueryVO) throws BusinessException {

        //获取展示集合
        PageObject<Object> resultVO = billViewQueryService.queryBillViewList(billViewQueryVO);

        if (ArrayUtils.isEmpty(resultVO.getObjects()))
            return new PageObject<Object>(new SuperVO[0], 0, billViewQueryVO.getPageStart());

        IBillViewCustomPlugin plugin = billViewPluginFactory.getBuziPlugin(billViewQueryVO.getBillType());

        if (plugin == null)
            return resultVO;
        //用于补充前端展示信息
        Object[] superVOs = plugin.fillListBuziField(resultVO.getObjects());
        resultVO.setObjects(superVOs);

        userInfoQuery.tranUserInfoField(resultVO.getObjects(), new String[]{CommonFieldConst.CREATOR, CommonFieldConst.CREATOR}, new String[]{CommonFieldConst.CREATOR_NAME, "creator_name"});
        return resultVO;
    }

    /**
     * 校验开始日期和结束日期
     *
     * @param billViewQueryVO
     * @return
     */
    private boolean checkDate(BillViewQueryVO billViewQueryVO) throws BusinessException {

        return validateDate(billViewQueryVO.getStartTime(),billViewQueryVO.getEndTime());
    }

     public boolean validateDate(String startTime, String endTime) throws BusinessException {
         if(StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) {
             return true;
         }
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");


         Date startDate = null;
         Date endDate = null;
         try {
             startDate = sdf.parse(startTime);
             endDate = sdf.parse(endTime);
         } catch (ParseException e) {
             throw new BusinessException(e.getMessage(), e);
         }

         if ((startDate.getTime() - endDate.getTime()) > 0)
             return false;
         return true;
     }
    private void fillData(HttpServletResponse response,BillViewQueryVO billViewQueryVO) throws BusinessException, IOException {
        String billType = billViewQueryVO.getBillType();
        //标题容器(beanList)/数据容器(dataList)
        List<ExcelExportEntity> beanList = new ArrayList<>();
        List<Map<String, Object>> dataList = new ArrayList<>();
        Object[] objects = getBillVOsExport(billViewQueryVO);
        if(billType.equals(BillTypeConst.PATROL_BILLTYPE)){//巡查记录
            //构造要导出的Excel的结构信息
            getBeanListXCJL(beanList);
            //构造要导出的excel对应的dataSet
            if(null != objects && objects.length > 0){
                for(int i = 0; i < objects.length; i++){
                    fillXCJL(dataList, objects[i], i);
                }
            }
            export(response, beanList, dataList,"安全文明巡查表","安全文明巡查表");
        }else if(billType.equals(BillTypeConst.CONSTRUCTIONLOG_BILLTYPE)){//施工记录
            //构造要导出的Excel的结构信息
            getBeanListSGJU(beanList);
            //构造要导出的excel对应的dataSet
            if(null != objects && objects.length > 0){
                for(int i = 0; i < objects.length; i++){
                    fillSGJU(dataList, objects[i], i);
                }
            }
            export(response, beanList, dataList,"施工记录检查表","施工记录检查表");
        }
    }

    private void check(BillViewQueryVO billViewQueryVO) throws BusinessException {
        String billType = billViewQueryVO.getBillType();
        if(!(billType.equals(BillTypeConst.PATROL_BILLTYPE) || billType.equals(BillTypeConst.CONSTRUCTIONLOG_BILLTYPE))){
            return;
        }
        //检查日期是否符合规范
        if (!checkDate(billViewQueryVO)){
            return;
        }
        //修饰日期
        String startTime = billViewQueryVO.getStartTime() + " 00:00:00";
        String endTime = billViewQueryVO.getEndTime() + " 23:59:59";
        billViewQueryVO.setStartTime(startTime);
        billViewQueryVO.setEndTime(endTime);
        billViewQueryVO.setPageStart(0);
        billViewQueryVO.setPageSize(Integer.MAX_VALUE);
    }

    private void export(HttpServletResponse response, List<ExcelExportEntity> beanList, List<Map<String, Object>> dataList,String tableName,String billTypeName) throws IOException {
        response.setHeader("content-Type", "application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(tableName,"UTF-8") + ".xls");
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(tableName, billTypeName), beanList , dataList);
        response.setCharacterEncoding("UTF-8");
        workbook.write(response.getOutputStream());
    }

    private void fillXCJL(List<Map<String, Object>> dataList, Object object, int i) {
        Map<String, Object> dataMap = new HashMap<>();
        SiteInspectionVO temp = (SiteInspectionVO) object;
        dataMap.put("num", ++i);//序号
        dataMap.put("projectName", temp.getProject_name());//项目名称
        dataMap.put("inspectarea", temp.getInspectarea());//检查部位
        dataMap.put("processName", temp.getProcess_name());//工序
        dataMap.put("inspectstandardName", temp.getInspectstandard_name());//检查标准
        dataMap.put("constructionName", temp.getConstruction_name());//施工单位
        dataMap.put("totItemNum", temp.getTotItemNum());//检查项总数
        dataMap.put("unPassNum", temp.getUnPassNum());//不合格项数
        dataMap.put("passRate", temp.getPassRate()+"%");//合格率
        dataMap.put("creatorName", temp.getCreator_name());//制单人
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        dataMap.put("creationtime", temp.getCreationtime() == null || temp.getCreationtime().equals("") ? "" : sdf.format(temp.getCreationtime()));//创建时间
        dataList.add(dataMap);
    }

    private void getBeanListXCJL(List<ExcelExportEntity> beanList) {
        ExcelExportEntity numEntity = new ExcelExportEntity("序号", "num");
        ExcelExportEntity projectNameEntity = new ExcelExportEntity("项目名称", "projectName");
        projectNameEntity.setWidth(40);
        ExcelExportEntity checPartEntity = new ExcelExportEntity("检查部位", "inspectarea");
        ExcelExportEntity processEntity = new ExcelExportEntity("工序", "processName");
        ExcelExportEntity checkStandardEntity = new ExcelExportEntity("检查标准", "inspectstandardName");
        checkStandardEntity.setWidth(40);
        ExcelExportEntity constructionOrganizationEntity = new ExcelExportEntity("施工单位", "constructionName");
        constructionOrganizationEntity.setWidth(40);
        ExcelExportEntity checkItemEntity = new ExcelExportEntity("检查项总数", "totItemNum");
        ExcelExportEntity disqualificationItemEntity = new ExcelExportEntity("不合格项数", "unPassNum");
        ExcelExportEntity percentOfPassEntity = new ExcelExportEntity("合格率", "passRate");
        ExcelExportEntity preparedEntity = new ExcelExportEntity("制单人", "creatorName");
        ExcelExportEntity preparedTimeEntity = new ExcelExportEntity("制单时间", "creationtime");
        beanList.add(numEntity);
        beanList.add(projectNameEntity);
        beanList.add(checPartEntity);
        beanList.add(processEntity);
        beanList.add(checkStandardEntity);
        beanList.add(constructionOrganizationEntity);
        beanList.add(checkItemEntity);
        beanList.add(disqualificationItemEntity);
        beanList.add(percentOfPassEntity);
        beanList.add(preparedEntity);
        beanList.add(preparedTimeEntity);
    }

    private void fillSGJU(List<Map<String, Object>> dataList, Object object, int i) {
        Map<String, Object> dataMap = new HashMap<>();
        ConstructionLogVO temp = (ConstructionLogVO) object;
        dataMap.put("num", ++i);//序号
        dataMap.put("projectName", temp.getProject_name());//项目名称
        dataMap.put("inspectarea", temp.getInspectarea());//检查部位
        dataMap.put("processName", temp.getProcess_name());//工序
        dataMap.put("inspectstandardName", temp.getInspectstandard_name());//检查标准
        dataMap.put("constructionName", temp.getConstruction_name());//施工单位
        dataMap.put("totItemNum", temp.getTotItemNum());//检查项总数
        dataMap.put("unPassNum", temp.getUnPassNum());//不合格项数
        dataMap.put("passRate", temp.getPassRate()+"%");//合格率
        dataMap.put("status", temp.getStrBillstatus());//审批状态
        dataMap.put("creatorName", temp.getCreator_name());//制单人
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        dataMap.put("creationtime", temp.getCreationtime() == null || temp.getCreationtime().equals("") ? "" : sdf.format(temp.getCreationtime()));//创建时间
        dataList.add(dataMap);
    }

    private void getBeanListSGJU(List<ExcelExportEntity> beanList) {
        ExcelExportEntity numEntity = new ExcelExportEntity("序号", "num");
        ExcelExportEntity projectNameEntity = new ExcelExportEntity("项目名称", "projectName");
        projectNameEntity.setWidth(40);
        ExcelExportEntity checPartEntity = new ExcelExportEntity("检查部位", "inspectarea");
        ExcelExportEntity processEntity = new ExcelExportEntity("工序", "processName");
        ExcelExportEntity checkStandardEntity = new ExcelExportEntity("检查标准", "inspectstandardName");
        checkStandardEntity.setWidth(40);
        ExcelExportEntity constructionOrganizationEntity = new ExcelExportEntity("施工单位", "constructionName");
        constructionOrganizationEntity.setWidth(40);
        ExcelExportEntity checkItemEntity = new ExcelExportEntity("检查项总数", "totItemNum");
        ExcelExportEntity disqualificationItemEntity = new ExcelExportEntity("不合格项数", "unPassNum");
        ExcelExportEntity percentOfPassEntity = new ExcelExportEntity("合格率", "passRate");
        ExcelExportEntity strBillstatusEntity = new ExcelExportEntity("审批状态", "status");
        ExcelExportEntity preparedEntity = new ExcelExportEntity("制单人", "creatorName");
        ExcelExportEntity preparedTimeEntity = new ExcelExportEntity("制单时间", "creationtime");

        beanList.add(numEntity);
        beanList.add(projectNameEntity);
        beanList.add(checPartEntity);
        beanList.add(processEntity);
        beanList.add(checkStandardEntity);
        beanList.add(constructionOrganizationEntity);
        beanList.add(checkItemEntity);
        beanList.add(disqualificationItemEntity);
        beanList.add(percentOfPassEntity);
        beanList.add(strBillstatusEntity);
        beanList.add(preparedEntity);
        beanList.add(preparedTimeEntity);
    }

}

@Data
class UserInfoRefVO {

    private String userId;
    private String userName;

}
